package cn.ljh.student.service.impl;
import cn.ljh.student.dao.RootMapper;
import cn.ljh.student.pojo.Root;
import cn.ljh.student.service.RootService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class RootServiceImpl implements RootService {

    @Resource
    private RootMapper rootMapper;

    public Root getRootById(String id)throws Exception{
        return rootMapper.getRootById(id);
    }

    public List<Root>	getRootListByMap(Map<String,Object> param)throws Exception{
        return rootMapper.getRootListByMap(param);
    }

    public Integer getRootCountByMap(Map<String,Object> param)throws Exception{
        return rootMapper.getRootCountByMap(param);
    }

    public Integer qdtxAddRoot(Root root)throws Exception{
            //root.setCreatedTime(new Date());
            return rootMapper.insertRoot(root);
    }

    public Integer qdtxModifyRoot(Root root)throws Exception{
        //root.setUpdatedTime(new Date());
        return rootMapper.updateRoot(root);
    }

    public Integer qdtxDeleteRootById(String id)throws Exception{
        return rootMapper.deleteRootById(id);
    }

    public Integer qdtxBatchDeleteRoot(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return rootMapper.batchDeleteRoot(param);
    }


}
